<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<html>
	<head>
		<title>广告编辑</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<%@ include file="/comm.jsp"%>
		<script>
		$(document).ready(function() {
			$("form *").autohelp("#autohelp");
		});
		  $(document).ready(function(){
		    $('#ok').click(function() { 
		    $('#adv_save').submit(); 
		    }) 
		    $("#adv_save").validate(
		    );
		  });

		</script>
		<script type="text/javascript">
			function preview(imgId, imgName){	
				var picId = document.getElementById(imgId).value;			
			    var fileext=picId.substring(picId.lastIndexOf("."),picId.length);   
			    fileext=fileext.toLowerCase();		
			    $("#fileext").val(fileext);   
			    validateImg(fileext, imgId);			    
			    showimage(imgName, picId);
			}
			
			function validateImg(fileext, imgId){
				if((fileext!='.jpg')&&(fileext!='.gif')&&(fileext!='.jpeg')&&(fileext!='.png')){
					alert("对不起，系统仅支持标准格式的照片，请您调整格式后重新上传，谢谢 !");   
			        document.getElementById(imgId).focus();  
				}
			}
			
			function showimage(imgName, imgId){
				$(imgName).html('');   
			    var newPreview =$(imgName)[0];     
				var imgDiv = document.createElement("div");
				document.body.appendChild(imgDiv);
				imgDiv.style.width = "140px";    
		        imgDiv.style.height = "110px";   
		        imgDiv.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod = scale)";      
		        imgDiv.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgId;
				newPreview.appendChild(imgDiv);			
			}
		</script>

		<style type="text/css">
<!--
fieldset {
	padding: 10px;
	margin: 10px;
	width: 270px;
	color: #333;
}

legend {
	color: #06c;
	font-weight: 800;
}
-->
</style>
	<body leftmargin="0" topmargin="0" marginheight="0">
		<s:form name="formpage" action="adv_save" namespace="/" method="POST"
			enctype="multipart/form-data">
			<s:token>
			</s:token>
			<div>
				<s:hidden id="hdfId" name="product.id"
					value="%{#request.product.id}" />
				<%@ include file="/messages.jsp"%>
				<table width="750">
					<tr>
						<td align="right" width="120">
							广告名称：
						</td>
						<td>
							<input name="adv.advName" type="text" value="${adv.advName }"
								maxlength="40" size="30" class="required" title="*必填" />
							(Action名称)
						</td>
					</tr>
					<tr>
						<td align="right" width="120">
							广告标题：
						</td>
						<td>
							<input name="adv.title" type="text" value="${adv.title }"
								maxlength="40" size="40" class="required" title="*必填" />
						</td>
					</tr>
					<tr>
						<td align="right">
							有效日期：
						</td>
						<td>
							<input id="dStartdate" name="adv.startDate"
								value='<s:date name="#request.adv.startDate" format="yyyy-MM-dd" />'
								size="13" class="Wdate" type="text"
								onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'dEnddate\')}'})" />
							至
							<input id="dEnddate" name="adv.endDate"
								value='<s:date name="#request.adv.endDate" format="yyyy-MM-dd" />'
								size="13" class="Wdate" type="text"
								onFocus="WdatePicker({minDate:'#F{$dp.$D(\'dStartdate\')}'})" />
						</td>
					</tr>
					<tr>
						<td align="right" width="120">
							链接网址：
						</td>
						<td>
							<input name="adv.linkUrl" type="text" value="${adv.linkUrl }"
								maxlength="80" size="60" class="required" title="*必填" />
						</td>
					</tr>
					<tr>
						<td align="right" valign="top">
							广告图片：
						</td>
						<td>
							<s:file title="图片1" name="myfile" size="50" id="myFile1"
								onchange="preview('myFile1','#imgDiv1')"></s:file>
							<div id="imgDiv1">
								<img src="" style="width: 140px; height: 110px;">
							</div>
						</td>
					</tr>
					<tr>
						<td align="right">
							语言过滤：
						</td>
						<td>
							<s:select list="#{'zh_CN':'中 文','en':'英 文'}" name="adv.lang"
								value="#request.adv.lang" id="lang">
							</s:select>
							(在中英文页面显示不同广告)
						</td>
					</tr>
					<tr>
						<td align="right" width="120">
							备&nbsp;&nbsp;注：
						</td>
						<td>
							<input name="adv.remark" type="text" value="${adv.remark }"	maxlength="40" size="30" />
						</td>
					</tr>
					<tr>
						<td></td>
						<td>
							<br/>
							<input type="submit" class="button" id="ok" name="ok"
								value=" 保 存 " />
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="button" class="button" id="resets" value=" 返 回 "
								onclick="javascript:history.go(-1)" />
						</td>
					</tr>
				</table>
			</div>
		</s:form>
	</body>
</html>